///<reference path="../typings/tsd.d.ts" />
module AUTO {
    export class DateBox{
        private _$el: JQuery;
        private _opt: DatepickerOptions;
        constructor(element: Element,mode:string,options?: DatepickerOptions) {
            let info={  "n":{format:'yyyy',startView:2 },
                        "ny":{format:'yyyymm',startView:1},
                        "nyr":{format:'yyyy-mm-dd',startView:0}
                     };
            this._$el = $(element);
            this._opt = $.extend( {     format:info[mode].format  ,
                                        weekStart: 1,
                                        autoclose: true,
                                        useCurrent:false,
                                        startView:  info[mode].startView ,
                                        minViewMode: info[mode].startView,
                                        //forceParse: false,  //必须设置，否则每次解析错，会变成1899年。
                                        language: 'zh-CN'
                                    }, options);
            this._$el.datepicker(this._opt);
        }
    }
}